﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ERPSystemApplication
{
    public partial class FrmProductInfo : Form
    {
        public FrmProductInfo()
        {
            InitializeComponent();
        }

        private void btnQuery_Click(object sender, EventArgs e)
        {

            this.dgvProductInfo.DataSource = SysController.ProductInfoController.GetProductList(this.txtCode.Text.Trim() == "请输入产品编号（多个编号用  ， 分隔）" ? "" : this.txtCode.Text.Trim());
            
        }

        #region txtCode 变化
        private void txtCode_TextChanged(object sender, EventArgs e)
        {
            if (txtCode.Text.Trim() != "")
            {
                txtCode.Text = txtCode.Text.Replace("\r\n", ",");
            }
        }

        private void txtCode_Enter(object sender, EventArgs e)
        {

            if (txtCode.Text.Trim() == txtCode.Tag.ToString().Trim())
            {
                txtCode.Text = "";
                txtCode.ForeColor = Color.Black;
            }
        }

        private void txtCode_Leave(object sender, EventArgs e)
        {

            if (txtCode.Text.Trim() == "")
            {
                txtCode.Text = txtCode.Tag.ToString().Trim();
                txtCode.ForeColor = Color.LightGray;
            }
            else
            {
                txtCode.Text = txtCode.Text.Replace("\r\n", ",").Trim(new char[] { ',' });

            }
        }
        #endregion

        private void dgvProductInfo_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string strUrl = string.Format("http://img.aorrd.com/{0}", this.dgvProductInfo.CurrentRow.Cells["WebPath"].Value.ToString());

            this.pic.BackgroundImage = Image.FromStream(System.Net.WebRequest.Create(strUrl).GetResponse().GetResponseStream());
            
            
        }

    }
}
